package com.leetcode.LC;

public class LC1629 {
    public char slowestKey(int[] releaseTimes, String keysPressed) {

        int maxTime=releaseTimes[0];
        char maxChar=keysPressed.charAt(0);

        for (int i = 1; i < releaseTimes.length; i++) {
            if (releaseTimes[i]-releaseTimes[i-1]>maxTime){
                maxTime=releaseTimes[i]-releaseTimes[i-1];
                maxChar=keysPressed.charAt(i);
            }else if (releaseTimes[i] - releaseTimes[i - 1] == maxTime){
                maxChar=keysPressed.charAt(i)>maxChar?keysPressed.charAt(i):maxChar;
            }
        }
        return maxChar;
    }
}
